<?php
/*
	[BuyPg] (C) 2010-2011 Buypg
	$Id: ShoppingNewsAction.class.php 2012-04-02 20:45:50 wufujun
*/

if (!defined('THINK_PATH')){
	exit('Access Denied');
}

class ShoppingNewsAction extends BpAction{
	public function index(){
		//购物攻略列表
		$ShoppingNewsModel = M("ShoppingNews");
		import("@.ORG.Page"); //导入分页类
		$count = $ShoppingNewsModel->where("status = 1")->count();    //计算总数
		$p = new Page ( $count, 20);
		$ShoppingNewsList = $ShoppingNewsModel->where("status = 1")->limit($p->firstRow.','.$p->listRows)->order('dateline DESC')->select();
		$p->setConfig('header','篇记录');
		$p->setConfig('prev','<');
		$p->setConfig('next','>');
		$p->setConfig('first','<<');
		$p->setConfig('last','>>');

		$p->setConfig('theme', ' <span>%totalRow% %header% %nowPage%/%totalPage% 页 </span> %first% %upPage% %linkPage% %downPage% %end%');
		$page = $p->show(1);
		//当前位置
		$position = " &gt; <a href='".U('BuyPg://ShoppingNews/')."'>购物攻略</a>";
		//模板输出
		$this->assign('page',$page);
		$this->assign('position' , $position);
		$this->assign('ShoppingNewsList',$ShoppingNewsList);
		$this->display('buypg@ShoppingNews:index');
	}

	public function view(){
		$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
		$ShoppingNewsModel = M("ShoppingNews");
		$ShoppingNews = $ShoppingNewsModel->where("id = {$id} and status = 1")->find();
		if(empty($ShoppingNews)){
			$this->redirect('/');
		}
		//统计点击
		$ShoppingNewsModel->setInc('apv',"id=$id",1);
		//当前位置
		$position = " &gt; <a href='".U('BuyPg://ShoppingNews/')."'>购物攻略</a> &gt; ".$ShoppingNews['title'];
		//SEO设置
		$SeoSet = array(
			'seotitle' => $ShoppingNews['title'],
			'seokeywords' => $ShoppingNews['seokeywords'],
			'seodescription' => $ShoppingNews['seodescription']
		);
		//模板输出
		$this->assign('ShoppingNews' , $ShoppingNews);
		$this->assign('SeoSet' , $SeoSet);
		$this->assign('position' , $position);
		$this->display('buypg@ShoppingNews:view');
	}
}
?>
